const conn = require('../db/config')

exports.tollevel = (req,res) => {
    conn.query('select id,name,cate_level as level from category',(err,result) => {
        if(err)  return console.log(err)
        if(result.length) {
            res.send({data:result})
        }
    })
}

exports.parlevel = (req,res) => {
    const par_id = req.query.id
    const sql = 'select id,name,cate_level as level from childkinds WHERE par_id = (select id from category WHERE id = ' + par_id + ')'
    conn.query(sql,(err,result) => {
        if(err) console.log(err)
        if(result.length) {
            res.send({data:result,status:200})
        }else{
            res.send({msg:'暂无数据',status:500})
        }
    })
}

exports.lastlevel = (req,res) => {
    const par_id = req.query.id
    const sql = 'select id,name,cate_level as level from lastchildkind WHERE par_id = (select id from childkinds WHERE id =' + par_id + ')'
    conn.query(sql,(err,result) => {
        if(err) console.log(err)
        if(result.length) {
            res.send({data:result,status:200})
        }else{
            res.send({msg:'暂无数据',status:500})
        }
    })
}

exports.deltollevel = (req,res) =>{
    
}
